<!doctype html>
<html>
<head>
<meta charset="utf-8">
    <title>红包收益</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">     
    <meta content="yes" name="apple-mobile-web-app-capable">     
    <meta content="black" name="apple-mobile-web-app-status-bar-style">     
    <meta content="telephone=no" name="format-detection">
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" type="text/css" href="/H5/css/sm.min.css" />
    <link rel="stylesheet" type="text/css" href="/H5/css/reset.css" />
    <link rel="stylesheet" type="text/css" href="/H5/css/commission.css?v=2" />
</head>            
<body>
	<div class="page-group ms-controller" :controller="packets">
        <div class="page page-current">
            <header class="bar bar-nav">
              	<a class="icon icon-left pull-left" href="javascript:window.history.go(-1);"></a>
              	<a class="icon icon-home pull-right" href="/H5"></a>
              	<h1 class="title">红包收益</h1>
            </header>
            <div class="content visibility infinite-scroll infinite-scroll-bottom" data-distance="100" style="padding-top: 80px;">
    			<div class="integral_balance" style="position: fixed; width: 100%; top: 2.5rem">
                	<div>红包总收益</div>
                    <div style="font-size:28px;">{{@data.total_red_packets||0}}</div>
                </div>
                <div class="table">
                    <a class="img_right"  :attr="{'href': '/H5/packetsdetail?&uid='+@data.uid}">
                        <img :attr="{'src': @data.avatar_url}"/>
                        <div class="tel_left">
                            <span style="float: left"><!-- {{@data.mobile||""}} -->红包总收益</span>
                            <span style="color:#0c0;float: right;font-size: 1rem">+{{@data.total_red_packets||0}}</span>
                        </div>
                        <div class="tel_right">
                            <span style="color:black;font-weight: normal; float: left;font-size: .8rem;">{{@data.real_name}}</span>
                            <span style="color:#0c0; font-weight: normal; float: right;font-size: .7rem; padding-right: 6%">今日红包收益:￥{{@data.day_red_packets||0}}</span>
                        </div>
                    </a>
                </div>
                <div :if="@more" class="infinite-scroll-preloader">
                    <div class="preloader"></div>
                </div>
			</div>
        </div>
    </div>
<script type='text/javascript' src='/H5/js/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/avalon.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/simpleStorage.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/mall.js?v=10' charset='utf-8'></script>
<script>
	var packets = avalon.define({
		$id: "packets",
		list: [],
        //type: Mall.parseUrl( window.location.href ).type,
        data: {},
        loading: false,
        more: false,
        page_num: 1,
        page_size: 10,
        packetsout: function(){
            Mall.request("/api/Packetsout")
              .always(function(data){
            	  //alert(data.data.s);
            	  if( data.error_code == 0 ){
            		  alert('恭喜您抢到'+data.data.packets+'元红包啦！');
            		  window.location.href='/H5/packets';  
	    			}
                         
              })
        }, 
		getPackets: function( t ){
            if( packets.loading ){
                return
            }
            packets.loading = true;
			Mall.request( "/api/Packets", {page_num: packets.page_num, page_size: packets.page_size, level: packets.type} )
				.always( function( data ){
                    if( data.error_code == 0 ){
                    	packets.data = data.data;
                    	packets.list = packets.list.concat( data.data.list );
                        if( packets.page_num == data.data.page_total ){
                        	packets.more = false;
                        }
                        else{
                            if( data.data.list.length == 0 ){
                            	packets.more = false;
                            }
                            else{
                            	packets.more = true;
                            }
                        }
                        packets.page_num ++;
                    }
                    packets.loading = false;
				} )
			$( ".content" ).removeClass( "visibility" )
		},
        infinite: function(){
            $(document).on('infinite', '.infinite-scroll-bottom',function() {
                if( packets.more ){
                	packets.getPackets();
                }
            });
            $.init();
        }
	})
    packets.getPackets();
	packets.infinite();
	

	avalon.scan( document.body )
</script>
</body>
</html>